<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<div class="navbar navbar-fixed-top">
	<div class="navbar-inner">
		<div class="container">
			<!-- Forum logo -->
			<a class="brand" href="${pageContext.request.contextPath}/index.jsp?lang=${lang}"><fmt:message key="title.short"/></a>
			
			<!--  Language picker -->
			<div class="btn-group pull-right">
				<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
					<i class="icon-flag"></i>
					${lang}
					<span class="caret"></span>
				</a>

				<ul class="dropdown-menu">
					<li><a href="?lang=en<c:if test="${param.id != null}">&id=${param.id}</c:if><c:if test="${param.name != null}">&name=${param.name}</c:if>">en</a></li>
					<li><a href="?lang=mk<c:if test="${param.id != null}">&id=${param.id}</c:if><c:if test="${param.name != null}">&name=${param.name}</c:if>">mk</a></li>
				</ul>
			</div>

			<c:choose>
				<c:when test="${user != null}">
					<!-- Logged user menu -->
					<ul class="nav pull-right">
						<li class="dropdown"><a href="#" class="dropdown-toggle"
							data-toggle="dropdown">${user.loginName}<b class="caret"></b>
						</a>

							<ul class="dropdown-menu">
								<li><a
									href="${pageContext.request.contextPath}/userEdit.jsp?lang=${lang}"><fmt:message
											key="settings" /></a></li>
								<li><a
									href="${pageContext.request.contextPath}#?lang=${lang}"><fmt:message
											key="messages" /></a></li>
								<li class="divider"></li>
								<li><a
									href="${pageContext.request.contextPath}/LoginController?lang=${lang}<c:if test="${param.id != null}">&id=${param.id}</c:if><c:if test="${param.name != null}">&name=${param.name}</c:if>"><fmt:message
											key="logout" /></a></li>
							</ul></li>
					</ul>
				</c:when>

				<c:otherwise>
					<!--  Login drop down -->
					<div class="nav-collapse pull-right">
						<ul class="nav">
							<li><a href="${pageContext.request.contextPath}/register.jsp?lang=${lang}"><fmt:message key="register"/></a></li>

							<li class="dropdown" id="menu1">
								<a class="dropdown-toggle"
									data-toggle="dropdown" href="#menu1"> 
									<fmt:message key="login"/>
									<b class="caret"></b>
								</a>

								<div class="dropdown-menu">
									<form action="LoginController" method="post">
										<fieldset class='textbox' style="padding: 10px">
											<input style="margin-top: 8px" name="username" type="text" placeholder="<fmt:message key="username"/>" /> 
											<input style="margin-top: 8px" name="password" type="password" placeholder="<fmt:message key="password"/>" /> 
											<input class="btn btn-primary" type="submit" value="<fmt:message key="login"/>"/>
											<input type="hidden" name="lang" value="${lang}">
										</fieldset>
									</form>
								</div>
							</li>
						</ul>
					</div>
				</c:otherwise>
			</c:choose>

			<!-- Search bar -->
			<form class="navbar-search pull-right" action="">
				<input type="text" class="search-query span2" placeholder="<fmt:message key="search"/>">
			</form>
		</div>
	</div>
</div>